vec <- c(1:10)
k <-0
for (variable in vec) {
  k <- k+variable
  print(k)
  
}
i<- 10
while(i>6){
  i<- i-1
  print(i)
}
#if else
if(i==5){
  print("i等于5")
  
}else{
  print("i不等于5")
}
#R的已有函数的复现



strsplit("abcd",split = "")


sum_fun <- function(x){
  y<- 0
  k <-0
  for (variable in x) {
    k <- k+variable
    print(k)
    
  }
  return(k)
}

# 实现按照参数输出不同列
# paper.data -> 张旭给我数据
# sp -> 分割列
# logic -> 逻辑  大还是等于 还是小于
# logicValue -> 数值
# sp1Name -> 列1 type 表头名称
# sp2Name -> 列2 type 表头名称
# 返回 合并后的表格

spdata_fun <- function(paper.data,sp,logic,logicValue,sp1Name,sp2Name){
  if (logic=='=') {
    return("ss")
    
  }

}
spdata_fun("aa","s" , "=d","dd","22","33")



ad <- sum_fun(vec)
print(ad)
#代码实现 sort 排序

# 首先搞有个正态分布 
ronrom_ls <- rnorm(10,mean=5,sd=1)
print(ronrom_ls)

sort_myfunc <- function(x){
  n <- length(x)
  for (i in c(1:(n-1))) {
    for (j in c(1:(n-i))) {
      if(x[j]>x[j+1]){
        x1 <- x[j]
        x2 <- x[j+1]
        x[j] <- x2
        x[j+1] <- x1
      }
      
    }
    
  }
  return(x)
  
}

sort_myfunc(ronrom_ls)



